package com.shux.springsource.property.editor;

import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2018年2月1日      Simba.Hua         Create
 * ****************************************************************************
 * </pre>
 * @author Simba.Hua
 */
public class DatePropertyEditor extends PropertyEditorSupport{
	private String format = "yyyy-MM-dd";

	public void setFormat(String format) {
		this.format = format;
	}
	@Override
	public void setAsText(String arg0) throws IllegalArgumentException {
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		try {
			Date date = sdf.parse(arg0);
			this.setValue(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
